<?php
	namespace app\service\admin;
	use core\BaseService;
	use app\model\Dic;
	use app\model\DicItem;
	use core\Util;
	class DicService extends BaseService{
		function model(){
			return Dic::$tableName;
		}
		
		function findDicItemsByKindId($kindId){
			return $this->table()
				->where('kind_id','=',$kindId)
				->orderBy('orders','asc')
				->get();
		}
		
		function saveDic($params,$info){
			if($params['id']){
				$params = Dic::filter($params);
				$this->update($params);
				$info->success =true;
				$info->msg = '操作成功，数据已更新！';
			}else{
				$params = Dic::filter($params);
				$time = Util::time();
				$params["create_time"] = $time;
				$this->insert($params);
				$info->success =true;
				$info->msg = '操作成功，数据已保存！';
			}
		}
	}